package com.ys.controller.api.mail;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.entity.mail.MailDraft;
import com.ys.service.sys.CommonApiService;
import com.ys.util.shiro.ShiroUtils;
import com.ys.vo.LayuiTableVoJA;

@Controller
@RequestMapping("/api/inter/mailDraft")
public class ApiInterMailDraftController {
	
	@Autowired
	private CommonApiService<MailDraft> commonApiService;

	@RequestMapping("/search")
    @ResponseBody
	public LayuiTableVoJA search(Model model, HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute MailDraft cond){
		
		String loginUserId = ShiroUtils.getUserId();
		
		cond.addLeftJoin("TS_UserChange C ON C.Id = A.CreateChangeId")
			.addField("C.UserId createUserId")
			.setStatus(1)
			.where("C.UserId = '" + loginUserId + "'");
		
		return commonApiService.searchLay(cond);
	}
}
